package com.dhq.myapp.util

import android.util.Log
import com.dhq.myapp.entity.GlassCompontent
import com.dhq.myapp.entity.GlassCompontentProp
import com.rokid.cxr.client.extend.CxrApi
import com.rokid.cxr.client.utils.ValueUtil
import java.util.ArrayList

/**
 * DESC 识别工具类
 * Created by DHQ on 2025/10/17.
 */
object IdentifyUtil {

//    companion object {
//        var result: GlassCompontent = GlassCompontent();


//    "{"+
//        "type": "LinearLayout",
//        "props": {
//            "layout_width": "match_parent",
//            "layout_height": "match_parent",
//            "orientation": "vertical",
//            "gravity": "center_horizontal",
//            "paddingTop": "140dp",
//            "paddingBottom": "100dp",
//            "backgroundColor": "#FF000000"
//        },
//        "children": [
//        {
//            "type": "TextView",
//            "props": {
//                "id": "tv_title",
//                "layout_width": "wrap_content",
//                "layout_height": "wrap_content",
//                "text": "Init Text",
//                "textSize": "16sp",
//                "textColor": "#FF00FF00",
//                "textStyle": "bold",
//                "marginBottom": "20dp"
//            }
//        }
//        ]
//    }"
//    }


//}

    @JvmStatic
    fun openCustomView(content: String): ValueUtil.CxrStatus {




        var result = GlassCompontent();
        var parentProps = GlassCompontentProp()
        parentProps.apply {
            layout_width = "match_parent"
            layout_height = "match_parent"
            orientation = "vertical"
            gravity = "center_horizontal"
            paddingTop = "140dp"
            paddingBottom = "100dp"
            backgroundColor = "#FF000000"
        }
        var textView = GlassCompontent()
        var textProps = GlassCompontentProp()

        textProps.apply {
            id = "tv_title"
            layout_width = "match_parent"
            layout_height = "match_parent"
            text = content
            textSize = "16sp"
            textColor = "#23FF1A"
            textStyle = "bold"
            marginBottom = "20dp"
        }
        textView.apply {
            type = "TextView"
            props = textProps;
        }
        var childList = ArrayList<GlassCompontent>()
        childList.add(textView)
        result.apply {
            type = "LinearLayout";
            props = parentProps;
            children = childList
        }

        Log.e("界面数据",DataUtils.gsonObjectToJson(result))

        return CxrApi.getInstance().openCustomView(DataUtils.gsonObjectToJson(result))
    }
}

//{
//        "type": "LinearLayout",
//        "props": {
//            "layout_width": "match_parent",
//            "layout_height": "match_parent",
//            "orientation": "vertical",
//            "gravity": "center_horizontal",
//            "paddingTop": "140dp",
//            "paddingBottom": "100dp",
//            "backgroundColor": "#FF000000"
//        },
//        "children": [
//            {
//                "type": "TextView",
//                "props": {
//                "id": "tv_title",
//                "layout_width": "wrap_content",
//                "layout_height": "wrap_content",
//                "text": "Init Text",
//                "textSize": "16sp",
//                "textColor": "#FF00FF00",
//                "textStyle": "bold",
//                "marginBottom": "20dp"
//            }
//        ]
//    }